package com.ht.base.system.biz.client.impl;

import com.ht.base.system.biz.manager.SysRoleMenuManager;
import com.ht.base.system.client.SysRoleMenuClient;
import org.base.common.appexception.AppException;
import org.base.common.appexception.ResultData;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

/**
 * @Author hdengxian
 * @Date 2023/8/15 17:27
 */
@DubboService
@Component
public class SysRoleMenuClientImpl implements SysRoleMenuClient {
    @Resource
    private SysRoleMenuManager sysRoleMenuManager;

    @Override
    public ResultData<Boolean> saveRoleMenuRelation(Long sysRoleId, List<Long> menuIdList) {
        return new ResultData<>(sysRoleMenuManager.saveRoleMenuRelation(sysRoleId, menuIdList));
    }

    @Override
    public ResultData<Boolean> deleteRelationByMenuId(Long sysMenuId) {
        return new ResultData<>(sysRoleMenuManager.deleteRelationByMenuId(sysMenuId));
    }

    @Override
    public ResultData<Set<String>> getPermission(Long sysRoleId) {
        return new ResultData<>(sysRoleMenuManager.getPermission(sysRoleId));
    }

    @Override
    public ResultData<List<Long>> getMenuIdListByUserId(Long sysRoleId) throws AppException {
        return new ResultData<>(sysRoleMenuManager.getMenuIdListByUserId(sysRoleId));
    }

    @Override
    public ResultData<Integer> countPermission(String permissionId, Long sysRoleId) throws AppException {
        return new ResultData<>(sysRoleMenuManager.countPermission(permissionId, sysRoleId));
    }
}
